package com.jeeplus.test.tools.resp;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.util.List;

@ApiModel("分页结果")
public class ZyPage<T> implements Serializable {
    @ApiModelProperty(
            value = "总数",
            required = true
    )
    private long total;
    @ApiModelProperty(
            value = "当前页面数",
            required = true
    )
    private int current;
    @ApiModelProperty(
            value = "每页最大数量",
            required = true
    )
    private int size;
    @ApiModelProperty(
            value = "数据列表",
            required = true
    )
    private List records;

    public static ZyPage getPage(List data, ZyPageRequest request, long total) {
        ZyPage zyPage = new ZyPage();
        zyPage.setCurrent(request.getPageNo());
        zyPage.setSize(request.getPageSize());
        zyPage.setRecords(data);
        zyPage.setTotal(total);
        return zyPage;
    }

    public static <T> ZyPage<T> getPageT(List<T> data, ZyPageRequest request, long total) {
        ZyPage<T> zyPage = new ZyPage();
        zyPage.setCurrent(request.getPageNo());
        zyPage.setSize(request.getPageSize());
        zyPage.setRecords(data);
        zyPage.setTotal(total);
        return zyPage;
    }

    public ZyPage() {
    }

    public long getTotal() {
        return this.total;
    }

    public int getCurrent() {
        return this.current;
    }

    public int getSize() {
        return this.size;
    }

    public List getRecords() {
        return this.records;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public void setCurrent(int current) {
        this.current = current;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public void setRecords(List records) {
        this.records = records;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof ZyPage)) {
            return false;
        } else {
            ZyPage<?> other = (ZyPage)o;
            if (!other.canEqual(this)) {
                return false;
            } else if (this.getTotal() != other.getTotal()) {
                return false;
            } else if (this.getCurrent() != other.getCurrent()) {
                return false;
            } else if (this.getSize() != other.getSize()) {
                return false;
            } else {
                Object this$records = this.getRecords();
                Object other$records = other.getRecords();
                if (this$records == null) {
                    if (other$records != null) {
                        return false;
                    }
                } else if (!this$records.equals(other$records)) {
                    return false;
                }

                return true;
            }
        }
    }

    protected boolean canEqual(Object other) {
        return other instanceof ZyPage;
    }

    public int hashCode() {
        boolean PRIME = true;
        int result = 1;
        long $total = this.getTotal();
        result = result * 59 + (int)($total >>> 32 ^ $total);
        result = result * 59 + this.getCurrent();
        result = result * 59 + this.getSize();
        Object $records = this.getRecords();
        result = result * 59 + ($records == null ? 43 : $records.hashCode());
        return result;
    }

    public String toString() {
        long var10000 = this.getTotal();
        return "ShunPage(total=" + var10000 + ", current=" + this.getCurrent() + ", size=" + this.getSize() + ", records=" + this.getRecords() + ")";
    }
}
